package cn.flying.cloud.system.dict.controller;

import javax.annotation.Resource;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.flying.cloud.base.common.vo.Rt;
import cn.flying.cloud.system.api.DictServiceApi;
import cn.flying.cloud.system.dict.service.DictDataService;

/**
 * 枚举字段码值表 前端控制器
 *
 * @author: admin
 * @date: 2023年04月19日 16:27
 * @version: 1.0
 */
@RestController
@RequestMapping("/system/dict")
public class DictApiController implements DictServiceApi {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource
    private DictDataService dictDataService;

    /**
     * 根据枚举类型查询枚举字典
     *
     * @param type
     * @return
     */
    @Override
    public Map<String, String> mapping(String type) {
        return dictDataService.getDict(type);
    }

    /**
     * 根据枚举类型查询枚举字典
     *
     * @param type
     * @return
     */
    @Override
    public Rt<?> data(String type) {
        Map<String, String> dict = dictDataService.getDict(type);
        return Rt.success("成功！", dict);
    }
}
